<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">

	<head>
		<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
		<title>登录</title>
		<link rel="stylesheet" type="text/css" href="../../css/login.css" />
		<script type="text/javascript" src="../../js/boot.js"></script>
	</head>

	<body>

	</body>

	<script type="text/javascript">
		var url = "https://aip.baidubce.com/oauth/2.0/token";
		/*var params = {
			grant_type: "client_credentials",
			client_id: "vPzEDC23ULI5Yr7YMPsppWM1",
			client_secret: "23ad8159c2906724d77ccdd5b83c0eea"
		};

		http.post(url, params, function(data) {
			if(data.access_token) {
				alert(data.access_token);
			} else {
				console.log(data);
			}
		});*/

		url = url + "?grant_type=client_credentials&client_id=vPzEDC23ULI5Yr7YMPsppWM1&client_secret=23ad8159c2906724d77ccdd5b83c0eea";
		/*http.get(url, function(data) {
			if(data.access_token) {
				alert(data.access_token);
			} else {
				console.log(data);
			}
		});*/

		/*$.ajax({
			type: 'GET',
			dataType: 'jsonp', // 数据类型配置成jsonp
			jsonp: "callback", //配置jsonp随机码标签,在服务器代码部分需要用到他来拼接一个json的js对象
			url: url, //服务路径
			async: false,
			data: {
				"type": '0',
			},
			success: function(response) {
				if(response.code == 200) {
					alert(response.access_token);
				} else {
					alert('服务器异常！');
				}
			},
			error: function() {
				alert('服务器异常！');
			}
		});*/

		function showLocation(data) {
			// 定位的地址信息 根据需要写入对象属性
			var locationInfo = {
				// 省份
				province: data.content.address_detail.province,
				// 城市
				city: data.content.address_detail.city
			}
			alert("检查到您的IP地址为" + locationInfo.province + locationInfo.city);
		}

		function location2() {
			url = "http://api.map.baidu.com/location/ip?ak=你的密钥&callback=showLocation";
			$.getScript(url);
		}

		location2();
	</script>

</html>